let mysql = require('mysql');
module.exports = (sql,params=[]) => {
    let connection = mysql.createConnection({
        host:'localhost',
        user:'root',
        password:'root',
        database:'08b-zk2'
    })

    connection.connect((error) => {
        if(error){
            console.log("链接失败")
        }else{
            console.log("链接成功")
        }
    })

    return new Promise((resolve,reject) => {
        connection.query(sql,params,(error,data) => {
            if(error){
                reject(error)
            }else{
                resolve(data);
            }
            connection.end();
        })
    })
}